import java.sql.*;

public class WorldSql1 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.jdbc.Driver");
        String jdbcUrl="jdbc:mysql://localhost:3308/world";
        String user="root";
        String password="";
        try(Connection conn = DriverManager.getConnection(jdbcUrl, user, password);
            Statement statement = conn.createStatement()) {
            ResultSet result =
                    statement.executeQuery("SELECT Name,Population FROM city WHERE Population>3017521");
            System.out.println("人口大于3017521的城市及人数:");
            while (result.next()){
                System.out.printf("%-20s\t%d\n",result.getString(1),result.getInt(2));
            }
        } catch(SQLException ex) {
            throw new RuntimeException(ex);
        }
    }
}